package cn.ytnet.shangyun.service.basic.entity;

import org.springframework.stereotype.Component;

import javax.persistence.*;

/**
 * Created by cyongk on 2015/12/8.
 * ClassName：SupplierEntity
 * ChineseName：供应商类
 */
@Component("supplierEntity")
@Entity
@Table(name = "T_Supplier", schema = "crebas", catalog = "")
public class SupplierEntity {
    private String pkTSupplierId;
    private String supplierName;
    private String supplierHead;
    private String supplierPhone;
    private String supplierMainbusiness;
    private int supplierBusinessNature;
    private String supplierScopeofbusiness;

    private ProvinceEntity provinceEntity;//省（直辖市）
    private CityEntity cityEntity;//市（地区、城市）
    private CountyEntity countyEntity;//县（区）
    private TownEntity townEntity;//镇（乡）

    @ManyToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "pk_t_province_id")
    public ProvinceEntity getProvinceEntity() {
        return provinceEntity;
    }

    public void setProvinceEntity(ProvinceEntity provinceEntity) {
        this.provinceEntity = provinceEntity;
    }

    @ManyToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "pk_t_city_id")
    public CityEntity getCityEntity() {
        return cityEntity;
    }

    public void setCityEntity(CityEntity cityEntity) {
        this.cityEntity = cityEntity;
    }

    @ManyToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "pk_t_county_id")
    public CountyEntity getCountyEntity() {
        return countyEntity;
    }

    public void setCountyEntity(CountyEntity countyEntity) {
        this.countyEntity = countyEntity;
    }

    @ManyToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "pk_t_town_id")
    public TownEntity getTownEntity() {
        return townEntity;
    }

    public void setTownEntity(TownEntity townEntity) {
        this.townEntity = townEntity;
    }

    @Id
    @Column(name = "pk_t_supplier_id", nullable = false, length = 18)
    public String getPkTSupplierId() {
        return pkTSupplierId;
    }

    public void setPkTSupplierId(String pkTSupplierId) {
        this.pkTSupplierId = pkTSupplierId;
    }

    @Basic
    @Column(name = "supplier_name", nullable = false, length = 60)
    public String getSupplierName() {
        return supplierName;
    }

    public void setSupplierName(String supplierName) {
        this.supplierName = supplierName;
    }

    @Basic
    @Column(name = "supplier_head", nullable = false, length = 20)
    public String getSupplierHead() {
        return supplierHead;
    }

    public void setSupplierHead(String supplierHead) {
        this.supplierHead = supplierHead;
    }

    @Basic
    @Column(name = "supplier_phone", nullable = false, length = 15)
    public String getSupplierPhone() {
        return supplierPhone;
    }

    public void setSupplierPhone(String supplierPhone) {
        this.supplierPhone = supplierPhone;
    }

    @Basic
    @Column(name = "supplier_mainbusiness", nullable = false, length = 3)
    public String getSupplierMainbusiness() {
        return supplierMainbusiness;
    }

    public void setSupplierMainbusiness(String supplierMainbusiness) {
        this.supplierMainbusiness = supplierMainbusiness;
    }

    @Basic
    @Column(name = "supplier_business_nature", nullable = false)
    public int getSupplierBusinessNature() {
        return supplierBusinessNature;
    }

    public void setSupplierBusinessNature(int supplierBusinessNature) {
        this.supplierBusinessNature = supplierBusinessNature;
    }

    @Basic
    @Column(name = "supplier_scopeofbusiness", nullable = false, length = 2)
    public String getSupplierScopeofbusiness() {
        return supplierScopeofbusiness;
    }

    public void setSupplierScopeofbusiness(String supplierScopeofbusiness) {
        this.supplierScopeofbusiness = supplierScopeofbusiness;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        SupplierEntity that = (SupplierEntity) o;

        if (supplierBusinessNature != that.supplierBusinessNature) return false;
        if (pkTSupplierId != null ? !pkTSupplierId.equals(that.pkTSupplierId) : that.pkTSupplierId != null)
            return false;
        if (supplierName != null ? !supplierName.equals(that.supplierName) : that.supplierName != null) return false;
        if (supplierHead != null ? !supplierHead.equals(that.supplierHead) : that.supplierHead != null) return false;
        if (supplierPhone != null ? !supplierPhone.equals(that.supplierPhone) : that.supplierPhone != null)
            return false;
        if (supplierMainbusiness != null ? !supplierMainbusiness.equals(that.supplierMainbusiness) : that.supplierMainbusiness != null)
            return false;
        return supplierScopeofbusiness != null ? supplierScopeofbusiness.equals(that.supplierScopeofbusiness) : that.supplierScopeofbusiness == null;

    }

    @Override
    public int hashCode() {
        int result = pkTSupplierId != null ? pkTSupplierId.hashCode() : 0;
        result = 31 * result + (supplierName != null ? supplierName.hashCode() : 0);
        result = 31 * result + (supplierHead != null ? supplierHead.hashCode() : 0);
        result = 31 * result + (supplierPhone != null ? supplierPhone.hashCode() : 0);
        result = 31 * result + (supplierMainbusiness != null ? supplierMainbusiness.hashCode() : 0);
        result = 31 * result + supplierBusinessNature;
        result = 31 * result + (supplierScopeofbusiness != null ? supplierScopeofbusiness.hashCode() : 0);
        return result;
    }
}
